import json


class JSONSuccess(object):
    
    def __init__(self, **kwargs):
        self.success = True
        for k,v in kwargs.items():
            setattr(self,k,v)
    
    def json(self):
        result = {}
        for i in dir(self):
            if not (i.startswith('_') or callable(getattr(self, i))):
                result[i] = getattr(self, i)
        return json.dumps(result)
    
    def __repr__(self):
        return self.json()


class JSONFailure(JSONSuccess):
    
    def __init__(self, **kwargs):
        self.success = False
        for k,v in kwargs.items():
            setattr(self,k,v)